/**
 * @create 2022-04-04
 * @desc hooks
 */

import { matchRoutes } from 'react-router-config';
import { useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { routerConfig } from '../routers';

export const useCurRoutes = () => {
  const { pathname } = useLocation();
  return useMemo(() => {
    const matchConfig = matchRoutes(routerConfig, pathname);

    return matchConfig.map((item) => item.route);
  }, [pathname]);
};
